package yt.demo.appcoresystem.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import yt.demo.appcommondb.base.BaseEntity;
import java.util.Date;
import java.util.List;

@EqualsAndHashCode(callSuper = false)
@Data
@Schema(name = "SystemLoginLog", description = "登录日志")
public class SystemLoginLog extends BaseEntity<SystemLoginLog> {

    @TableId
    @Schema(name = "id", description = "主键ID")
    @NotNull(message = "id不能为空") // 更新时确保此字段不能为空
    private Long id;

    @Schema(description = "用户名")
    private String username;

    @Schema(description = "IP")
    private String ip;

    @JsonProperty("ip_location")
    @Schema(description = "IP所属地")
    private String ipLocation;

    @Schema(description = "操作系统")
    private String os;

    @Schema(description = "浏览器")
    private String browser;

    @Schema(description = "状态 (1正常 2停用)")
    private Integer status;

    @Schema(description = "提示消息")
    private String message;

    @Schema(description = "登录时间")
    @JsonProperty("login_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date loginTime;

    @Schema(description = "备注")
    private String remark;

    @TableField(exist = false)
    private List<String> searchTime;

    @TableField(exist = false)
    private Date createTime;

    @TableField(exist = false)
    private Date updateTime;

    @TableField(exist = false)
    private Date deletedAt;

}
